<%--
  Created by IntelliJ IDEA.
  User: dell
  Date: 2024/8/9
  Time: 14:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Login</title>
    <link href="static/layui/css/layui.css" rel="stylesheet">
</head>
<body>
    <form id="formId" method="post">
        <table>
            <tr>
                <td>用户名：</td>
                <td><input type="text" name="name"></td>
            </tr>
            <tr>
                <td>密码：</td>
                <td><input type="text" name="password"></td>
            </tr>
            <tr>
                <td>验证码：</td>
                <td><input type="text" name="code"><img src="/verifyCode"></td>
            </tr>
        </table>
        <tr><input type="button" onclick="submitForm()" value="登录"></tr>
    </form>

    <script src="static/layui/layui.js" type="text/javascript" charset="UTF-8"></script>
    <script src="static/jquery-2.1.4.js" type="text/javascript" charset="UTF-8"></script>
    <script src="static/mylayer.js" type="text/javascript" charset="UTF-8"></script>

    <script>
        function submitForm() {
            $.post(
                "/user?method=login",
                $("#formId").serialize(),
                function (result) {
                    console.log(result);
                    if(result.code == 0) {
                        mylayer.okUrl(result.msg,"/");
                    } else {
                        mylayer.errorMsg((result.msg));
                    }
                },
                "json"
            )
        }
    </script>
</body>
</html>
